package com.dragon.logical.service.avttendance.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dragon.logical.service.avttendance.IArrangePeriodService;
import com.dragon.repository.entity.ArrangePeriod;
import com.dragon.repository.mapper.ArrangePeriodMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 考勤配置时段 服务实现类
 * </p>
 *
 * @author sy
 * @since 2023-07-31
 */
@Service
public class ArrangePeriodServiceImpl extends ServiceImpl<ArrangePeriodMapper, ArrangePeriod> implements IArrangePeriodService {

    @Autowired
    ArrangePeriodMapper periodMapper;

    @Override
    public void periodAdd(Integer arrangeId, ArrangePeriod period) {
        period.setArrangeId(arrangeId);
        periodMapper.insert(period);
    }

    @Override
    public void periodUpdate(ArrangePeriod period) {
        periodMapper.updateById(period);
    }

    @Override
    public void periodDelete(Integer id) {
        periodMapper.deleteById(id);
    }

    @Override
    public List<ArrangePeriod> showList(Integer arrangeId) {
        QueryWrapper<ArrangePeriod> wrapper = new QueryWrapper<>();
        wrapper.lambda().eq(ArrangePeriod::getArrangeId,arrangeId);
        List<ArrangePeriod> periods = periodMapper.selectList(wrapper);
        return periods;
    }
}
